package com.cmyshare.design.strategyAndFactory;

/**
 * @version 1.0
 * @Author cmy
 * @Date 2025/10/13 14:21
 * @desc 测试主类 支付系统中结合工厂模式和策略模式
 */
public class FactoryAndStrategyTest {
    public static void main(String[] args) {
        // 创建支付上下文，指定支付方式
        PaymentContext paymentContext = new PaymentContext("alipay");
        paymentContext.executePayment(100.50);

        // 切换支付方式
        paymentContext.setPaymentStrategy("wechat");
        paymentContext.executePayment(200.00);

        // 使用银联支付
        paymentContext.setPaymentStrategy("unionpay");
        paymentContext.executePayment(350.75);
    }
}
